package com.service;

import com.dao.UserMapper;
import com.model.UserModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author lizhenzhong
 * @date 2018-09-05 14:12:33
 */
@Slf4j  
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	/**
	 * 查询列表
	 *
	 * @param userModel
	 * @return List<UserModel>
	 */
	@Override
	public List<UserModel> list(UserModel userModel) {
		return userMapper.list(userModel);
	}


	/**
	 * 查询详情
	 *
	 * @param id
	 * @return UserModel
	 */
	@Override
    //@Cacheable(value = "userCart#120#120", key = "#cartId", sync = true)
	public UserModel getDetails(long id) {
		return userMapper.getDetails(id);
	}

	/**
	 * 新增
	 *
	 * @param userModel
	 * @return long
	 */
	@Override
    //@CachePut(value = "userCart", key = "#cartId")
	public long save(UserModel  userModel) {
		userMapper.save(userModel);
		return userModel.getId();
	}

	/**
	 * 批量新增
	 *
	 * @param userModelList
	 * @return int
	 */
	@Override
	public int batchSave(List<UserModel>  userModelList) {
		return userMapper.batchSave(userModelList);
	}

	/**
	 * 更新
	 *
	 * @param userModel
	 * @return int
	 */
	@Override
	//@CacheEvict(value = "user", key = "#id")
	public int update(UserModel userModel) {
		return userMapper.update(userModel);
	}

	/**
	 * 删除
	 *
	 * @param userModel
	 * @return int
	 */
	@Override
	//@CacheEvict(value = "user", key = "#id")
	public int delete(UserModel userModel) {
		return userMapper.delete(userModel);
	}

	/**
	 * 查询总数
	 *
	 * @param userModel
	 * @return long
	 */
	@Override
	public long count(UserModel userModel) {
		return userMapper.count(userModel);
	}
}